#include "head.h"

void *threadMain(void *p){

    thread_status* pthread_info = (thread_status*)p;
    int socket_fd = socket(AF_INET, SOCK_STREAM, 0);

    char ip[100] = {0};
    load_config("ip", ip);
    char port[100] = {0};
    load_config("port", port);
    struct sockaddr_in addr;
    addr.sin_family = AF_INET;
    addr.sin_port = htons(atoi(port));
    addr.sin_addr.s_addr = inet_addr(ip);

    connect(socket_fd, (struct sockaddr *)&addr, sizeof(addr));
    // 初始化请求报文

    if(pthread_info->request->flag == PUTS)
        {
            net_puts(socket_fd,pthread_info);
        }
    else if(pthread_info->request->flag == GETS)
        {
            net_gets(socket_fd,pthread_info);
        }
    return NULL;
}
    